// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0


TestCase := Rectangle {
    property<int> top_level: 4;
    property<int> active_index: 0;
    property<int> some_prop: 5;
    property<int> another_prop: 100;
    text1 := Text {
        property<int> foo: 85 + top_level;
    }

    states [
        xxx when active_index == 1 : {
            text1.foo: 3 + 2 * top_level;
            some_prop: 2000;
            in {
                animate some_prop { duration: 100ms; }
            }
            out {
                animate text1.foo { duration: 300ms; }
            }
        }

        yyy when active_index == 3 : {
            another_prop: 500;
            in-out {
                animate another_prop { duration: 100ms; }
            }
        }
    ]

    property<int> text1_foo: text1.foo;

}




/*

```rust
let instance = TestCase::new().unwrap();
assert_eq!(instance.get_text1_foo(), 85 + 4);
assert_eq!(instance.get_some_prop(), 5);
instance.set_active_index(1);
assert_eq!(instance.get_text1_foo(), 3 + 2 * 4);
assert_eq!(instance.get_some_prop(), 5);
slint_testing::mock_elapsed_time(75); // 75% the animation
assert!(instance.get_some_prop() > 1500);
assert!(instance.get_some_prop() < 1999);
slint_testing::mock_elapsed_time(30); // more than 100% the animation
assert_eq!(instance.get_some_prop(), 2000);

instance.set_active_index(2);
assert_eq!(instance.get_some_prop(), 5);
assert_eq!(instance.get_text1_foo(), 3 + 2 * 4);
slint_testing::mock_elapsed_time(290);
assert!(instance.get_text1_foo() > 70);
assert!(instance.get_text1_foo() < 87);
slint_testing::mock_elapsed_time(30);
assert_eq!(instance.get_text1_foo(), 85 + 4);

assert_eq!(instance.get_another_prop(), 100);
instance.set_active_index(3);
assert_eq!(instance.get_another_prop(), 100);
slint_testing::mock_elapsed_time(75); // 75% of the animation
assert!(instance.get_another_prop() > 100);
assert!(instance.get_another_prop() < 500);
slint_testing::mock_elapsed_time(25); // 100% of the animation
assert_eq!(instance.get_another_prop(), 500);

instance.set_active_index(1);
assert_eq!(instance.get_another_prop(), 500);
slint_testing::mock_elapsed_time(75); // 75% of the animation
assert!(instance.get_another_prop() > 100);
assert!(instance.get_another_prop() < 500);
slint_testing::mock_elapsed_time(25); // 100% of the animation
assert_eq!(instance.get_another_prop(), 100);
```


```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.get_text1_foo(), 85 + 4);
assert_eq(instance.get_some_prop(), 5);
instance.set_active_index(1);
assert_eq(instance.get_text1_foo(), 3 + 2 * 4);
assert_eq(instance.get_some_prop(), 5);
slint_testing::mock_elapsed_time(75); // 75% the animation
assert(instance.get_some_prop() > 1500);
assert(instance.get_some_prop() < 1999);
slint_testing::mock_elapsed_time(30); // more than 100% the animation
assert_eq(instance.get_some_prop(), 2000);

instance.set_active_index(2);
assert_eq(instance.get_some_prop(), 5);
assert_eq(instance.get_text1_foo(), 3 + 2 * 4);
slint_testing::mock_elapsed_time(290);
assert(instance.get_text1_foo() > 70);
assert(instance.get_text1_foo() < 87);
slint_testing::mock_elapsed_time(30);
assert_eq(instance.get_text1_foo(), 85 + 4);

assert_eq(instance.get_another_prop(), 100);
instance.set_active_index(3);
assert_eq(instance.get_another_prop(), 100);
slint_testing::mock_elapsed_time(75); // 75% of the animation
assert(instance.get_another_prop() > 100);
assert(instance.get_another_prop() < 500);
slint_testing::mock_elapsed_time(25); // 100% of the animation
assert_eq(instance.get_another_prop(), 500);

instance.set_active_index(1);
assert_eq(instance.get_another_prop(), 500);
slint_testing::mock_elapsed_time(75); // 75% of the animation
assert(instance.get_another_prop() > 100);
assert(instance.get_another_prop() < 500);
slint_testing::mock_elapsed_time(25); // 100% of the animation
assert_eq(instance.get_another_prop(), 100);
```


```js
var instance = new slint.TestCase({});
assert.equal(instance.text1_foo, 85 + 4);
assert.equal(instance.some_prop, 5);
instance.active_index = 1;
assert.equal(instance.text1_foo, 3 + 2 * 4);
assert.equal(instance.some_prop, 5);
slintlib.private_api.mock_elapsed_time(75); // 75% the animation
assert(instance.some_prop > 1500);
assert(instance.some_prop < 1999);
slintlib.private_api.mock_elapsed_time(30); // more than 100% the animation
assert.equal(instance.some_prop, 2000);

instance.active_index = 2;
assert.equal(instance.some_prop, 5);
assert.equal(instance.text1_foo, 3 + 2 * 4);
slintlib.private_api.mock_elapsed_time(290);
assert(instance.text1_foo > 70);
assert(instance.text1_foo < 87);
slintlib.private_api.mock_elapsed_time(30);
assert.equal(instance.text1_foo, 85 + 4);

assert.equal(instance.another_prop, 100);
instance.active_index = 3;
assert.equal(instance.another_prop, 100);
slintlib.private_api.mock_elapsed_time(75); // 75% of the animation
assert(instance.another_prop > 100);
assert(instance.another_prop < 500);
slintlib.private_api.mock_elapsed_time(25); // 100% of the animation
assert.equal(instance.another_prop, 500);

instance.active_index = 1;
assert.equal(instance.another_prop, 500);
slintlib.private_api.mock_elapsed_time(75); // 75% of the animation
assert(instance.another_prop > 100);
assert(instance.another_prop < 500);
slintlib.private_api.mock_elapsed_time(25); // 100% of the animation
assert.equal(instance.another_prop, 100);
```

*/
